package eu.gline.km.actors;

import java.io.IOException;

import eu.gline.km.clients.KmClient;
import eu.gline.km.protocol.PROTOCOL;

public class MouseActor {
	
	private KmClient kmClient;
	
	public MouseActor(KmClient kmClient) {
		this.kmClient = kmClient;
	}
	
	public void mousePos(int x, int y) {
		try {
			kmClient.getDos().writeInt(PROTOCOL.MousePos);
			kmClient.getDos().writeInt(x);
			kmClient.getDos().writeInt(y);
			kmClient.getDos().flush();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void mouseUp(int x) {
		try {
			kmClient.getDos().writeInt(PROTOCOL.MouseUp);
			kmClient.getDos().writeInt(x);
			kmClient.getDos().flush();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void mouseDown(int x) {
		try {
			kmClient.getDos().writeInt(PROTOCOL.MouseDown);
			kmClient.getDos().writeInt(x);
			kmClient.getDos().flush();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void mouseLeft(int x) {
		try {
			kmClient.getDos().writeInt(PROTOCOL.MouseLeft);
			kmClient.getDos().writeInt(x);
			kmClient.getDos().flush();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void mouseRight(int x) {
		try {
			kmClient.getDos().writeInt(PROTOCOL.MouseRight);
			kmClient.getDos().writeInt(x);
			kmClient.getDos().flush();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void mouseEvent(int dwEvents, int x, int y, int dwData) {
		try {
			kmClient.getDos().writeInt(PROTOCOL.MouseEvent);
			kmClient.getDos().writeInt(dwEvents);
			kmClient.getDos().writeInt(x);
			kmClient.getDos().writeInt(y);
			kmClient.getDos().writeInt(dwData);
			kmClient.getDos().flush();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
